package com.inspur.mr.parelectric;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class ElectricPartitionMapper  extends Mapper<LongWritable, Text,Text, Text>{
	@Override
	protected void map(LongWritable key, Text value, Context context)
			throws IOException, InterruptedException {
			String[] split = value.toString().split(";");
			if (split.length == 11) {
				   if (!(split[8].equals("?")||split[9].equals("?")||split[10].equals("?"))){
					   String month = split[1];
					   double cf =  Double.parseDouble(split[8]);
					   double xyf =  Double.parseDouble(split[9]);
					   double kt =  Double.parseDouble(split[10]);
					   String result = cf + "\t" + xyf + "\t" + kt ;
					   context.write(new Text(month), new Text(result));
 				   }
			}
	}
}